package mybatisTest.reflect;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.junit.Test;
import pojo.Dog;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试生成对象
 */
public class ObjectFactoryTest {
    /**
     * 创建默认构造函数的对象
     */
    @Test
    public void test1(){
        ObjectFactory objectFactory=new DefaultObjectFactory();
        Dog dog1 = objectFactory.create(Dog.class);
        System.out.println(dog1);
    }
    /**
     * 创建参数构造函数的对象
     */
    @Test
    public void test2(){
        ObjectFactory objectFactory=new DefaultObjectFactory();
        List<Class<?>> argsType=new ArrayList<>();
        argsType.add(String.class);argsType.add(int.class);
        List<Object> args=new ArrayList<>();
        args.add("xiaohua");args.add(44);
        Dog dog1 = objectFactory.create(Dog.class,argsType,args);
        System.out.println(dog1);
    }
}
